package com.senlingspace.system.service.impl;

import java.util.List;

import com.senlingspace.common.utils.DateUtils;
import com.senlingspace.common.utils.NumberGenerator;
import com.senlingspace.common.utils.PageUtils;
import com.senlingspace.common.utils.SecurityUtils;
import com.senlingspace.system.domain.vo.SlkjProductTypeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.senlingspace.system.mapper.SlkjProductTypeMapper;
import com.senlingspace.system.domain.SlkjProductType;
import com.senlingspace.system.service.ISlkjProductTypeService;

/**
 * 商品类别Service业务层处理
 *
 * @author wangliang
 * @date 2024-07-30
 */
@Service
public class SlkjProductTypeServiceImpl implements ISlkjProductTypeService {
    @Autowired
    private SlkjProductTypeMapper slkjProductTypeMapper;

    /**
     * 查询商品类别
     *
     * @param typeId 商品类别主键
     * @return 商品类别
     */
    @Override
    public SlkjProductType selectSlkjProductTypeByTypeId(Long typeId) {
        return slkjProductTypeMapper.selectSlkjProductTypeByTypeId(typeId);
    }

    /**
     * 查询商品类别列表
     *
     * @param slkjProductType 商品类别
     * @return 商品类别
     */
    @Override
    public List<SlkjProductType> selectSlkjProductTypeList(SlkjProductType slkjProductType) {
        PageUtils.startPage();
        return slkjProductTypeMapper.selectSlkjProductTypeList(slkjProductType);
    }

    @Override
    public List<SlkjProductTypeVo> selectCheck() {

        return slkjProductTypeMapper.selectCheck();
    }

    /**
     * 新增商品类别
     *
     * @param slkjProductType 商品类别
     * @return 结果
     */
    @Override
    public int insertSlkjProductType(SlkjProductType slkjProductType) {
        slkjProductType.setCreateBy(SecurityUtils.getUsername());
        slkjProductType.setTypeNo(NumberGenerator.productNumber());
        return slkjProductTypeMapper.insertSlkjProductType(slkjProductType);
    }

    /**
     * 修改商品类别
     *
     * @param slkjProductType 商品类别
     * @return 结果
     */
    @Override
    public int updateSlkjProductType(SlkjProductType slkjProductType) {
        slkjProductType.setUpdateTime(DateUtils.getNowDate());
        slkjProductType.setUpdateBy(SecurityUtils.getUsername());
        return slkjProductTypeMapper.updateSlkjProductType(slkjProductType);
    }


    /**
     * 删除商品类别信息
     *
     * @param typeId 商品类别主键
     * @return 结果
     */
    @Override
    public int deleteSlkjProductTypeByTypeId(Long typeId) {
        SlkjProductType slkjProductType = slkjProductTypeMapper.selectSlkjProductTypeByTypeId(typeId);
        slkjProductType.setDelFlag("1");
        slkjProductType.setUpdateBy(SecurityUtils.getUsername());
        slkjProductType.setUpdateTime(DateUtils.getNowDate());
        return slkjProductTypeMapper.updateSlkjProductType(slkjProductType);
    }
}
